// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV
})

// 云函数入口函数
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()
  const result = await cloud.openapi.subscribeMessage.send({
    touser:wxContext.OPENID,
    page:`/pages/news-comment/news-comment?newsId=${event.newsId}`,
    data:{
      phrase2:{
        value:'评价完成'
      },
      thing3:{
        value:event.content
      }
    },
    templateId:'DdjmN85HHReenlmRCOTVMmFJ4Ld2j1eU9ms8LbKseAQ'
  })
  return result
  // return {
  //   event,
  //   openid: wxContext.OPENID,
  //   appid: wxContext.APPID,
  //   unionid: wxContext.UNIONID,
  // }
}